// on content load inject active, enabled scripts
function eventContentLoad(e) {
	try {
		TH_ifSchemeAllowed(function () {
			var scripts = TH_getInfo('scripts').filter(function (script) {
				if (script.active == 'true' && script.enabled == 'true')
					return true;

				return false;
			});

			TH_injectScriptsDefault(scripts);
		});
	} catch (e) {};
}

// on unload remove mem leaks
function eventUnload() {
	window.removeEventListener('DOMContentLoaded', eventContentLoad, false);
	window.removeEventListener('unload', eventUnload, false);
}

// set events for onload and DOMContentLoad
window.addEventListener('DOMContentLoaded', eventContentLoad, false);
window.addEventListener('unload', eventUnload, false);